export default function (url, formData) {
    return new Promise((resolve, reject) => {
        const xhr = new XMLHttpRequest();
        xhr.onreadystatechange = function () {
            if (xhr.readyState == 4) {
                if (xhr.staus == 200) {
                    resolve(JSON.parse(xhr.responseText))
                } else {
                    if (xhr.status == 401) {
                        alert('您未登录或登录超时，请重新登录')
                        top.location.assign('/manage/login.html')
                    };
                    reject(xhr.status)
                }
            }
        }
        xhr.open('post', url, true)
        xhr.setRequestHeader('Authorization', 'Bearer ' + localStorage.getItem('token'));
        xhr.send(formData)
    })
}